<?php

class Solution
{

    /**
     * @param String $haystack
     * @param String $needle
     * @return Integer
     */
    function strStr($haystack, $needle)
    {
        $strLen = strlen($needle);

        if ($strLen == 0) {
            return 0;
        }

        $allLen = strlen($haystack);
        for ($i = 0; $i <= $allLen - $strLen; $i++) {
            $subStr = substr($haystack, $i, $strLen);
            echo $subStr . PHP_EOL;
            if ($needle == $subStr) {
                return $i;
            }
        }

        return -1;

    }
}
